# -*- coding: UTF-8 -*-
# Author: Damon(wuud1)
# CreateDate: 
# Message:
import xlrd
from MysqlTools import MysqlTools

workbook = xlrd.open_workbook(r'/Users/duanmengdi/Desktop/JAC_finally.xlsx')
sheet = workbook.sheet_by_index(0)
rows = sheet.nrows
print(rows)
i = 1
db_ = dict(
    host="127.0.0.1",
    port=3306,
    user="root",
    passwd="123456",
    db="JAC",
    charset="utf8",
)
db = MysqlTools(db_config=db_, type='dict', auto_commit=100)
while True:
    if i == rows:
        # print(i)
        break
    row_info = sheet.row_values(i)
    i += 1
    # print(row_info)
    id=row_info[0]
    structrue_name=row_info[1]
    group_name=row_info[2]
    group_num=row_info[3]
    in_sql = '''insert into `strcture_name_finally` (`id`,`structrue_name`,`group_name`,`group_num`) value ("{}","{}","{}","{}")'''.format(id, structrue_name, group_name, group_num)
    db.execute_sql(in_sql)
db.commit_sql()

